﻿using StoryPlan.Models;
using System.Linq;
using System.Net;
using System.Web.Http;

namespace StoryPlan.Api
{
    public class ApiControllerBase : ApiController
    {
        protected int GetUserId()
        {
            var context = new UsersContext();

            var user = context.UserProfiles.FirstOrDefault(u => u.UserName == User.Identity.Name);

            if (user == null)
                throw new HttpResponseException(HttpStatusCode.InternalServerError);

            return user.UserId;
        }
    }
}